//
//  Prefix.h
//  Bettle
//
//  Created by yangdongxu on 2016/10/4.
//  Copyright © 2016年 yangdongxu. All rights reserved.
//

#ifndef Prefix_h
#define Prefix_h


#import "UIView+Frame.h"
#import "Masonry.h"

#endif /* PrefixHeader_pch */
#define KeyWindow       [[UIApplication sharedApplication] keyWindow]
#define MainWindow      [[[UIApplication sharedApplication] delegate] window]
//DEBUG  模式下打印日志,当前 行

#ifdef DEBUG // 调试状态, 打开LOG功能
#define NSLog(FORMAT, ...) fprintf(stderr,"[%s:%d行]\n %s\n\n",__func__, __LINE__, [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
#define BNBLog(...) NSLog(__VA_ARGS__)
#else // 发布状态, 关闭LOG功能
#define BNBLog(...)
#endif


/** 多线程GCD*/
#define GlobalGCD(block) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block)
#define MainGCD(block) dispatch_async(dispatch_get_main_queue(),block)

//按照比例适配  实际的高度和宽度 按照6来适配
#define SHIJI_HEIGHT SCREEN_HEIGHT/667
#define  SHIJI_WIDTH SCREEN_WIDTH/375
//获取屏幕 宽度、高度
#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)
#define SCREEN_SHIJI_WIDTH ([UIScreen mainScreen].nativeScale * SCREEN_WIDTH)
#define SCREEN_SHIJI_HEIGHT ([UIScreen mainScreen].nativeScale * SCREEN_HEIGHT)


//格式转化
#define StringWithFormat(Object) [NSString stringWithFormat:@"%@",Object]

//alloc
#define ALLOC(Object,view) Object *view = [[Object alloc]init];
//Frame
#define FRAME(view,x,y,width,height) view.frame = CGRectMake(x, y, width, height);
//Alloc,Frame
#define ALLOC_FRAME(Object,view,x,y,width,height) ALLOC(Object,view)\
FRAME(view,x,y,width,height)

//定义一个避免引用循环的weakself
#define  WeakSelf(name,className)  __weak typeof(className)name=className;

#define  ISNULL(content) [content isKindOfClass:[NSNull class]]||[StringWithFormat(content) isEqualToString:@"(null)"]||content==nil||[StringWithFormat(content) isEqualToString:@"<null>"]||[StringWithFormat(content) isEqualToString:@""]||[StringWithFormat(content) isEqualToString:@" "]

//定义一个判断属性是否为空 是的的话赋值一个默认字符串  例子：IsNilString(model.sign,@"这个人还没有签名");
#define  UsePlaceHolderReplaceNil(property,placeHolderString)  ISNULL(property)?placeHolderString:StringWithFormat(property)
//判断一个属性是否为空 如果是 用@"" 空来代替 避免出现 null的情况
#define  UseSpaceReplaceNil(property)  ISNULL(property)?@"":StringWithFormat(property)


//StringWithFormat
#define StringWithFormat(Object) [NSString stringWithFormat:@"%@",Object]

//定义UIImage对象
#define IMAGE(imageName) [UIImage imageNamed:[NSString stringWithFormat:@"%@",imageName]]

//AddTargetInside
#define ADD_TARGET_INSIDE(ButtonName,Selector) [ButtonName addTarget:self action:@selector(Selector) forControlEvents:UIControlEventTouchUpInside];
//ButtonSetimage title
#define BUTTON_SETIMAGE(ButtonName,imageName) [ButtonName setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
#define BUTTON_SETIMAGESELECTED(ButtonName,imageName) [ButtonName setImage:[UIImage imageNamed:imageName] forState:UIControlStateSelected];

#define BUTTON_SETTITLE(ButtonName,Title) [ButtonName setTitle:Title forState:UIControlStateNormal];
#define BUTTON_TITLECOLOR(ButtonName,TitleColor)    [ButtonName setTitleColor:TitleColor forState:UIControlStateNormal];

// rgb颜色转换（16进制->10进制）
#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]

//红色
#define REDCOLOR UIColorFromRGB(0xFF554C)
//灰色
#define  LIGHTGRAYCOLOR UIColorFromRGB(0xCCCCCC)
// 获取RGB颜色
#define RGBA(r,g,b,a) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a]
#define RGB(r,g,b) RGBA(r,g,b,1.0f)

//#define DefaultBackGroundColor UIColorFromRGB(0xf5f5f5)

#define NAVBARCOLOR RGBA(0,0,0,0.82f)


#define ViewBorderRadius(View, Radius, Width, Color)\
\
[View.layer setCornerRadius:(Radius)];\
[View.layer setMasksToBounds:YES];\
[View.layer setBorderWidth:(Width)];\
View.layer.rasterizationScale = View.layer.contentsScale;\
[View.layer setBorderColor:[Color CGColor]]



